package com.niiwoo.civet.scheduler.configuration;

import com.niiwoo.civet.trade.constant.RabbitConstant;
import org.springframework.amqp.core.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * Created by zhangwanli on 2017/11/17.
 */
@Configuration
public class InvestmentMqConfiguration {

    //**********************
    //自动投资配置
    //**********************
    @Bean
    public Exchange autoInvestProjectExchange() {
        return new DirectExchange(RabbitConstant.Exchange.AUTO_INVEST_PROJECT, true, true);
    }

    @Bean
    public Queue autoInvestProjectQueue() {
        return new Queue(RabbitConstant.Queue.AUTO_INVEST_PROJECT, true);
    }

    @Bean
    public Binding autoInvestProjectBinding() {
        return BindingBuilder.bind(autoInvestProjectQueue()).to(autoInvestProjectExchange()).with(RabbitConstant.RoutingKey.AUTO_INVEST_PROJECT).noargs();
    }

    //**********************
    //批量投资配置
    //**********************

    @Bean
    public Exchange batchInvestorExchange() {
        return new DirectExchange(RabbitConstant.Exchange.BATCH_INVESTOR, true, true);
    }

    @Bean
    public Queue batchInvestorQueue() {
        return new Queue(RabbitConstant.Queue.BATCH_INVESTOR, true);
    }

    @Bean
    public Binding batchInvestorBinding() {
        return BindingBuilder.bind(batchInvestorQueue()).to(batchInvestorExchange()).with(RabbitConstant.RoutingKey.BATCH_INVESTOR).noargs();
    }

}
